﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using Lswweb.Model;
using Lswweb.Domain;


namespace Lswweb.Controls
{
    public class CommentaryList : SkinnedGridView<CommentaryInfo>
    {
        public CommentaryList()
        {
            this.IsBack = SiteContext.Current.IsTrue;
        }
        
        protected override IList<CommentaryInfo> GridViewDataSourceHandler(int pageIndex, int pageSize, out int totalRecord)
        {
            if (ProductId > 0)
            {
                return Products.GetCommentaries(ProductId, pageIndex, pageSize, out totalRecord);
            }
            else if (UserId > 0)
            {
                return Products.GetCommentaryByUser(UserId, pageIndex, pageSize, out totalRecord);
            }
            else
            {
                return Products.GetCommentaries(IsBack, pageIndex, pageSize, out totalRecord);
            }
        }

        private int productId=SiteContext.Current.CategoryId;
        public int ProductId
        {
            get { return this.productId; }
            set { this.productId = value; }
        }

        public int ProductCategoryId { get; set; }

        public int UserId { get; set; }

        protected override string DefaultSkinFilename
        {
            get { return string.Empty; }
        }

        public bool? IsBack { get; set; }
    }
}
